/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package menu;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.*;
public class Menu {
		JFrame f = new JFrame("菜单");
		JPanel p = new JPanel();
		Menu(){
		JButton b_depart = new JButton("院系信息");
		JButton b_student = new JButton("学生信息");
		JButton b_course = new JButton("课程信息");
		JButton b_score = new JButton("成绩信息");
		JButton ex = new JButton("退出");
		b_score.addActionListener(new Monitor2());
		ex.addActionListener(new Monitor2());
		b_depart.addActionListener(new Monitor2());
		b_student.addActionListener(new Monitor2());
		b_course.addActionListener(new Monitor2());
		f.addWindowListener(new Wind());
		f.add(p);
		p.setLayout(new GridLayout(1,2));
		JLabel l = new JLabel();
		JPanel p2 = new JPanel();
		p.add(l);
		p.add(p2);
		p2.setLayout(new GridLayout(5,1));
		p2.add(b_depart);
		p2.add(b_student);
		p2.add(b_course);
		p2.add(b_score);
		p2.add(ex);
		f.setBounds(400,200,400,400);
		f.setVisible(true);
		}
		public static void main(String args[]){
			new Menu();
		}
		private class Wind extends WindowAdapter{
			public void windowClosing(WindowEvent e) {
				f.setVisible(false);
				System.exit(0);	
			}
		}
		private class Monitor2 implements ActionListener{
		    	
		    	public void actionPerformed(ActionEvent e) {
		    		if(e.getActionCommand().equals("退出")){
		    			new Menu();
			    		System.exit(0);	   	
		    			}
	    		if(e.getActionCommand().equals("学生信息")){
	    			new Son_menu().studentmenu();
		    		f.setVisible(false);	   	
	    			}
		    	
		    	if(e.getActionCommand().equals("院系信息")){
	    			new Son_menu().departmenu();
		    		f.setVisible(false);	   	
	    			}
		    	
		    	if(e.getActionCommand().equals("课程信息")){
	    			new Son_menu().coursemenu();
		    		f.setVisible(false);	   	
	    			}
		    	if(e.getActionCommand().equals("成绩信息")){
	    			new Son_menu().scoremenu();
		    		f.setVisible(false);	   	
	    			}
		    }
		}
}
